NikMik Posted March 26, 2014 Share Posted March 26, 2014 I can do a prefab postinit just fine, but I've never seen a stategraph postinit besides Dana Addams' Link mod. But that's adding complete new states and I'll admit, I'm not quite familiar enough with postinits to understand what to change about it, if anything at all. So, I have two questions: Is it possible to create a stategraph postinit to edit an existing event and state? In this case, editing the doattack event to make a custom bow state like this: EventHandler("doattack", function(inst) if not inst.components.health:IsDead() and not inst.sg:HasStateTag("attack") then local weapon = inst.components.combat and inst.components.combat:GetWeapon() if weapon and weapon:HasTag("blowdart") then inst.sg:GoToState("blowdart") elseif weapon and weapon:HasTag("thrown") then inst.sg:GoToState("throw") elseif weapon and weapon:HasTag("bow") then inst.sg:GoToState("bow") else inst.sg:GoToState("attack") end end end), and the attack state itself to add some neat combo-y things to a specific character. If it's possible, any help at all would be greatly appreciated.Help can range to just a poke in the right direction to an example. An example would work well since that's how I learn best. Thanks for reading, and even more thanks if you can (even if it doesn't work) help me! Link to comment https://forums.kleientertainment.com/forums/topic/33582-re-writing-a-state-and-event-with-a-postinit/ Share on other sites More sharing options...
simplex Posted March 26, 2014 Share Posted March 26, 2014 You could do something like this:AddStategraphPostInit("wilson", function(sg) local old_doattack = sg.events.doattack.fn sg.events.doattack.fn = function(inst, data) if not inst.components.health:IsDead() and not inst.sg:HasStateTag("attack") then local weapon = inst.components.combat and inst.components.combat:GetWeapon() if weapon and weapon:HasTag("bow") then inst.sg:GoToState("bow") else return old_doattack(inst, data) end end endend)AddStategraphState("wilson", GLOBAL.State { name = "bow", onenter = function(inst) print("hi") end, onexit = function(inst) print("bye") end,}) Link to comment https://forums.kleientertainment.com/forums/topic/33582-re-writing-a-state-and-event-with-a-postinit/#findComment-438284 Share on other sites More sharing options...
NikMik Posted March 26, 2014 Author Share Posted March 26, 2014 Thank you very much! Link to comment https://forums.kleientertainment.com/forums/topic/33582-re-writing-a-state-and-event-with-a-postinit/#findComment-438314 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now